package com.hrms.controller;

import com.hrms.domain.Employee;
import com.hrms.domain.web.AjaxResult;
import com.hrms.domain.web.TableDataInfo;
import com.hrms.service.EmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author:zhao xinyu
 * @date: 2024/12/19 - 11:39
 * @mail: zxy1277692924@outlook.com
 * @info:
 */
@Slf4j
@RequestMapping("/admin/employee")
@RestController
public class EmployeeController extends BaseController{

    @Autowired
    private EmployeeService employeeService;

//    @GetMapping("/list")
//    public AjaxResult page(@RequestParam(defaultValue = "1") Integer page ,
//                           @RequestParam(defaultValue = "10") Integer pageSize){
//        log.info("查询员工信息, page={}, pageSize={}", page, pageSize);
//        PageBean pageBean = employeeService.page(page, pageSize);
//        return AjaxResult.success(pageBean);
//    }

    /**
     * 查询员工管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Employee employee)
    {
        startPage();
        List<Employee> list = employeeService.selectEmployeeList(employee);
        return getDataTable(list);
    }

    /**
     * 新增员工
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody Employee employee)
    {
        return toAjax(employeeService.insertEmployee(employee));
    }


}
